package com.ysd.lis.controller;


import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.PubTaskTemplet;
import com.ysd.lis.service.PubTaskTempletService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 样品可配置项分类表 前端控制器
 * </p>
 *
 * @author LiuQi
 * @since 2023-11-13
 */
@Api(tags = "模版管理")
@RestController
@RequestMapping("/api/task/templet")
public class PubTaskTempletController extends BaseController {

    @Autowired
    private PubTaskTempletService pubTaskTempletService;

    @ApiOperation("根据页面id查询模板列表")
    @GetMapping("/findTaskTempletListByPageId/{pageId}")
    public Result findTaskTempletListByPageId(@PathVariable("pageId") String pageId) {
        return pubTaskTempletService.findTaskTempletListByPageId(pageId);
    }

    @ApiOperation("根据模版id tableName查询实例数据")
    @GetMapping("/getTempletTestList/{tableName}/{templetId}")
    public Result getTempletTestList(@PathVariable("tableName") String tableName, @PathVariable("templetId") String templetId) {
        return pubTaskTempletService.getTempletTestList(tableName, templetId);
    }

    @ApiOperation("添加模版")
    @PostMapping("/addTaskTemplet")
    @LogDetail(requestParam = "addTaskTemplet", operationType = OperationType.INSERT, module = "模版管理", content = "通过模版管理，增加标题为【title】模版", businessName = "title")
    public Result addTaskTemplet(@RequestBody PubTaskTemplet pubTaskTemplet) {
        return pubTaskTempletService.addTaskTemplet(pubTaskTemplet);
    }

    @ApiOperation("编辑模版")
    @PostMapping("/editTaskTemplet")
    @LogDetail(requestParam = "editTaskTemplet", operationType = OperationType.UPDATE, module = "模版管理", content = "通过模版管理，编辑标题为【title】模版", businessName = "title")
    public Result editTaskTemplet(@RequestBody PubTaskTemplet pubTaskTemplet) {
        return pubTaskTempletService.editTaskTemplet(pubTaskTemplet);
    }

    @ApiOperation("删除模版")
    @PostMapping("/deleteTaskTemplet")
    @LogDetail(requestParam = "deleteTaskTemplet", operationType = OperationType.DELETE, module = "模版管理", content = "通过模版管理，删除标题为【title】模版", businessName = "title")
    public Result deleteTaskTemplet(@RequestBody PubTaskTemplet pubTaskTemplet) {
        return pubTaskTempletService.deleteTaskTemplet(pubTaskTemplet);
    }
}
